from django.urls import re_path, path, include
from rest_framework_simplejwt.views import TokenRefreshView

from . import views
from . import file_controller
from users import views as user_views
from .animation import views as animation_views

urlpatterns = [
    # ---------------------------------------------------------------
    # API的健康检查（无需认证）
    re_path(r'^health/?$', views.health_check, name='health'),
    # 用户认证相关
    re_path(r'^auth/register/?$',
            user_views.RegisterView.as_view(), name='register'),
    re_path(r'^auth/login/?$', user_views.LoginView.as_view(), name='login'),
    re_path(r'^auth/logout/?$', user_views.LogoutView.as_view(), name='logout'),
    re_path(r'^auth/token/refresh/?$',
            TokenRefreshView.as_view(), name='token_refresh'),
    # 第三方登录
    re_path(r'^auth/other/login/?$', user_views.ThirdPartyLoginView.as_view(),
            name='third_party_login'),
    # 用户资料管理
    re_path(r'^auth/me/?$', user_views.UserProfileView.as_view(),
            name='user_profile'),
    re_path(r'^auth/profile/?$', user_views.UserProfileView.as_view(),
            name='user_profile_alt'),
    re_path(r'^auth/change-password/?$',
            user_views.ChangePasswordView.as_view(), name='change_password'),
    re_path(r'^auth/stats/?$', user_views.user_stats, name='user_stats'),
    # 用户管理（管理员功能）
    re_path(r'^users/?$', user_views.UserListView.as_view(),
            name='user_management_list'),
    re_path(r'^users/(?P<pk>\d+)/?$', user_views.UserDetailView.as_view(),
            name='user_management_detail'),

    # 剪映项目模板创建接口
    re_path(r'^jianying/template/create/?$',
            views.create_jianying_template, name='create_jianying_template'),

    # 项目创建接口
    re_path(r'^create-project/?$', views.create_jianying_template,
            name='create_project'),

    # 文件上传接口
    path('files/upload', file_controller.upload_file, name='upload_file'),
    path('files/delete/<path:object_key>',
         file_controller.delete_file, name='delete_file'),
    path('files/url', file_controller.get_file_url, name='get_file_url'),

    # 生成视频预览接口 - 修改路径匹配前端请求
    re_path(r'^preview/?$', views.generate_preview_video,
            name='generate_preview_video'),

    # 动画相关接口
    re_path(r'^animations/text/?$', views.get_text_animations,
            name='get_text_animations'),
    re_path(r'^animations/categories/?$',
            animation_views.get_animation_categories, name='get_animation_categories'),
]
